<template>
  <div v-if="isShow" @click="toggleShow">
    <div id="poplayer">
      <img :src="'http://elm.cangdu.org/img/'+food.image_path" alt="菜样图片">
      <div class="food_DES">
        <p>{{food.name}}</p>
        <span>￥{{food.specfoods[0].price}}</span>
        <cartControl :food="food"></cartControl>
      </div>
    </div>
    <div id="covered"></div>
  </div>
</template>
<script>
import cartControl from "../cartControl/cartControl.vue";
export default {
  data() {
    return {
      isShow: false
    };
  },
  props: {
    food: Object
  },
  methods: {
    toggleShow() {
      this.isShow = !this.isShow;
    }
  },
  components: {
    cartControl
  }
};
</script>
<style lang="scss" scoped>
/* 弹出层 */
#poplayer {
  position: absolute;
  top: 40%;
  left: 50%;
  margin-left: -150px;
  margin-top: -100px;
  width: 300px;
  height: 200px;
  z-index: 8888;
  background: white;
  font-size: 20px;
  color: orangered;
  .food_DES {
    display: flex;
    justify-content: space-around;
    background: white;
  }
}
/* 底层 */
#covered {
  position: fixed;
  z-index: 888;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: Black;
  opacity: 0.3;
}
</style>
